﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameLib.Utils
{
	public static class StringConvert
	{
		public static object FromString(string str, Type type)
		{
			Converter<string, object> converter;
			if (Converters.TryGetValue(type, out converter))
				return converter(str);

			return Convert.ChangeType(str, type);
		}

		private static Dictionary<Type, Converter<string, object>> Converters;
	}
}
